﻿using Microsoft.Xna.Framework.Graphics;
using XnaContentManager = Microsoft.Xna.Framework.Content.ContentManager;

namespace WindowsGame.Manager
{
	/// <summary>
	/// ContentManager is responsible for managing all content load/unload in game.
	/// </summary>
	public interface IContentManager
	{
		void LoadContent(XnaContentManager xnaContent);
		void UnloadContent();
		Model SpaceShipModel { get; }
	}

	public class ContentManager : IContentManager
	{
		// ContentManager has dependency on DeviceManager.
		private readonly IDeviceManager deviceManager;
		private XnaContentManager content;

		public ContentManager(IDeviceManager deviceManager)
		{
			this.deviceManager = deviceManager;
		}

		// Load all content.
		public void LoadContent(XnaContentManager xnaContent)
		{
			if (null != content)
			{
				return;
			}

			content = xnaContent;
			content.RootDirectory = deviceManager.DeviceFactory.RootDirectory;
			SpaceShipModel = content.Load<Model>("Models/p1_wedge");
		}

		// Unload all content.
		public void UnloadContent()
		{
			if (null == content)
			{
				return;
			}

			content.Unload();
		}

		public Model SpaceShipModel { get; private set; }
	}
}